package com.distributer.product.thread;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;

import com.distributer.product.request.Request;

public class RequestQueue {

	public final List<ArrayBlockingQueue<Request>> queues;
	
	public final Map<String, Boolean> flagMap;
	
	private RequestQueue(){
		this.queues = new ArrayList<ArrayBlockingQueue<Request>>(10);
		this.flagMap = new ConcurrentHashMap<String, Boolean>();
	}
	
	private static class RequestQueueInstance{
		
		private static RequestQueue requestQueue = null;
		
		static{
			requestQueue = new RequestQueue();
		}
		
		public static RequestQueue getInstance(){
			return requestQueue;
		}
	}
	
	public static RequestQueue getInstance(){
		return RequestQueueInstance.getInstance();
	}
	
	public List<ArrayBlockingQueue<Request>> getRequestQueues(){
		return queues;
	}
	
	public void add(ArrayBlockingQueue<Request> requestQueue){
		this.queues.add(requestQueue);
	}
	
	public Map<String, Boolean> getFlagMap(){
		return this.flagMap;
	}
	
	public ArrayBlockingQueue<Request> getQueueByIndex(int index){
		return this.queues.get(index);
	}
}
